package com.atguigu.yygh.task.scheduled;

import com.atguigu.common.rabbit.constant.MqConst;
import com.atguigu.common.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ybl
 * @version 1.9
 * @date 2021/5/31 17:21
 * 定时任务
 */
@Component
@EnableScheduling
public class ScheduledTask {

  @Autowired
  private RabbitService rabbitService;

  // @Scheduled(cron = "0/30 * * * * ?") // 三十秒执行一次
  @Scheduled(cron = "0 0 8 * * ?") // 每天八点执行一次
  public void task1(){
    rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"");
  }
}
